package com.landeb.shop.huo.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.landeb.shop.R;

/**
 * Created by blade on 2016/11/12.
 */

public class FootView extends LinearLayout {

    private LayoutInflater mInflater;
    private LinearLayout mToRefresh, mRefreshing, mFinished;
    private View mView;


    public FootView(Context context) {
        super(context);

        mInflater = LayoutInflater.from(context);
        mView = mInflater.inflate(R.layout.item_foot_view, null);

        LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        addView(mView, params);
        setGravity(Gravity.CENTER);
        setBackgroundResource(R.color.white);

        mToRefresh = (LinearLayout) mView.findViewById(R.id.footView_toRefresh);
        mRefreshing = (LinearLayout) mView.findViewById(R.id.footView_refreshing);
        mFinished = (LinearLayout) mView.findViewById(R.id.footView_finished);

    }

    public FootView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        mInflater = LayoutInflater.from(context);
        mView = mInflater.inflate(R.layout.item_foot_view, null);

        LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        addView(mView, params);
        setGravity(Gravity.CENTER);
        setBackgroundResource(R.color.white);

        mToRefresh = (LinearLayout) mView.findViewById(R.id.footView_toRefresh);
        mRefreshing = (LinearLayout) mView.findViewById(R.id.footView_refreshing);
        mFinished = (LinearLayout) mView.findViewById(R.id.footView_finished);
    }

    public FootView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mInflater = LayoutInflater.from(context);
        mView = mInflater.inflate(R.layout.item_foot_view, null);

        LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        addView(mView, params);
        setGravity(Gravity.CENTER);
        setBackgroundResource(R.color.white);

        mToRefresh = (LinearLayout) mView.findViewById(R.id.footView_toRefresh);
        mRefreshing = (LinearLayout) mView.findViewById(R.id.footView_refreshing);
        mFinished = (LinearLayout) mView.findViewById(R.id.footView_finished);
    }


    public void setToRefresh() {
        mToRefresh.setVisibility(VISIBLE);
        mRefreshing.setVisibility(INVISIBLE);
        mFinished.setVisibility(INVISIBLE);
    }

    public void setRefreshing() {
        mToRefresh.setVisibility(INVISIBLE);
        mRefreshing.setVisibility(VISIBLE);
        mFinished.setVisibility(INVISIBLE);
    }

    public void setFinished() {
        mToRefresh.setVisibility(INVISIBLE);
        mRefreshing.setVisibility(INVISIBLE);
        mFinished.setVisibility(VISIBLE);
    }
}
